<template>
  <div class="control-item">
    <div class="control-header">
      <span class="control-name">模块标题</span>
      <span @click="showBeautyBox = true">组件美化</span>
    </div>
    <div class="control-body">
      <div class="control-section">
        <!-- 字体配置 -->
        <fontControl
          controlName="标题文字"
          :fontData="params.params.moduleNameCss"
          :showAlign="false"
          @resetFontCss="resetModuleNameCss"
        ></fontControl>
        <!-- 字体配置 -->
        <fontControl
          controlName="更多文字"
          :fontData="params.params.moduleMoreCss"
          :showAlign="false"
          @resetFontCss="resetModuleMoreCss"
        ></fontControl>
        <!-- 标题 -->
        <div class="control-item title-section">
          <div class="control-title flex-between">
            <span>副标题文字</span>
            <span class="reset" @click="resetMoreText">重置</span>
          </div>
          <div class="control-content">
            <div class="title-name-input">
              <a-input
                placeholder="请输入副标题文字"
                v-model="params.params.moreText"
              />
            </div>
            <div class="hidden-icon" @click="handleHiddenIcon">
              <i
                class="iconfont icon-xianshi"
                v-if="params.params.showMoreText"
              ></i>
              <i class="iconfont icon-yincang" v-else></i>
            </div>
          </div>
        </div>
        <!-- 选择链接 -->
        <div class="link-box">
          <chooseLink
            :link="params.params.link"
            @chooseEnd="chooseLink"
          ></chooseLink>
        </div>
      </div>
    </div>
    <!-- 组件美化 -->
    <comBeautyBox
      :showBeautyBox="showBeautyBox"
      @handleBack="showBeautyBox = false"
    >
      <div>
        <!-- 背景配置 -->
        <bgControl :backgroudData="params.params.headerBg"></bgControl>
      </div>
    </comBeautyBox>
  </div>
</template>

<script>
import fontControl from "@/components/DiyNew/diy/baseControl/fontControl/index.vue";
import chooseLink from "@/components/DiyNew/chooseLink/index.vue";
import comBeautyBox from "@/components/DiyNew/diy/comBeautyBox/comBeautyBox.vue";
import bgControl from "@/components/DiyNew/diy/baseControl/bgControl/index.vue";

export default {
  name: "editProductModuleHeader",
  components: {
    fontControl,
    chooseLink,
    comBeautyBox,
    bgControl,
  },
  props: {
    params: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      showBeautyBox: false,
    };
  },
  watch: {},
  computed: {},
  methods: {
    // 重置字体样式
    resetModuleNameCss() {
      let style = Object.assign({}, pageHeader.params.moduleNameCss);
      this.$set(this.params.params, "moduleNameCss", style);
    },
    resetModuleMoreCss() {
      let style = Object.assign({}, pageHeader.params.moduleMoreCss);
      this.$set(this.params.params, "moduleMoreCss", style);
    },
    // 点击隐藏按钮
    handleHiddenIcon() {
      let flag = this.params.params.showMoreText ? false : true;
      this.$set(this.params.params, "showMoreText", flag);
    },
    resetMoreText() {
      this.$set(this.params.params, "moreText", "更多");
    },
    chooseLink(e) {
      console.log(e);
      this.$set(this.params.params, "link", e);
    },
  },
};
</script>

<style lang="scss" scoped>
.control-item {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  .control-header {
    width: 100%;
    height: 48px;
    background: #ffffff;
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px 14px 24px;
    span {
      font-size: 12px;
      color: #8c8c8c;
    }
    .control-name {
      font-size: 14px;
      font-weight: 600;
      color: #000000;
    }
    span:nth-child(2) {
      cursor: pointer;
    }
  }
  .control-body {
    width: 100%;
    .control-section {
      width: 228px;
      margin: 0 auto;
      text-align: center;
      .control-item {
        width: 100%;
        .control-title {
          padding: 24px 0 14px 0;
          font-size: 12px;
          color: #000000;
          text-align: left;
        }
        .control-content {
          .example-list {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            .example-item {
              width: 70px;
              height: 70px;
              background: #f6f7f9;
              border-radius: 4px;
              margin-right: 6px;
              margin-bottom: 8px;
              display: flex;
              justify-content: center;
              align-items: center;
              cursor: pointer;
              img {
                width: 70px;
                height: 70px;
              }
            }
            .example-item:last-child {
              margin-right: 0;
            }
            .active {
              border: 2px solid #1890fc;
            }
          }
          .buy-style-list {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            .buy-item {
              width: 70px;
              height: 44px;
              background: #f6f7f9;
              border-radius: 4px;
              display: flex;
              justify-content: center;
              align-items: center;
              margin-right: 8px;
              cursor: pointer;
              .icon-weibiaoti-14 {
                font-size: 22px;
              }
              .add-box {
                width: 24px;
                height: 24px;
                background: #444444;
                border-radius: 8px;
                display: flex;
                justify-content: center;
                align-items: center;
                .iconfont {
                  font-size: 23px;
                  color: #ffffff;
                }
              }
              .word-box {
                width: 42px;
                height: 24px;
                background: #444444;
                border-radius: 60px;
                position: relative;
                .white {
                  width: 20px;
                  height: 6px;
                  background: #ffffff;
                  border-radius: 30px;
                  position: absolute;
                  left: 11px;
                  top: 9px;
                }
              }
            }
            .buy-item:last-child {
              margin-right: 0;
            }
            .active {
              border: 2px solid #1890fc;
            }
          }
        }
        .buyBtnText {
          width: 226px;
          height: 40px;
          border-radius: 4px;
          ::v-deep .ant-input {
            width: 100%;
            height: 100%;
            border: 0 none;
            background: #f6f7f9;
          }
        }

        .space-set {
          .space-set-body {
            width: 100%;
            height: 40px;
            background: #f6f7f9;
            border-radius: 4px;
            display: flex;
            align-items: center;
            padding-left: 14px;
            .iconfont {
              font-size: 20px;
            }
            .slider {
              margin: 0 16px;
              width: 100px;
              ::v-deep .ant-slider-track {
                background-color: #1890fc;
              }
              ::v-deep .ant-slider-rail {
                background-color: #e6e6e6;
              }
            }
            .slider-input {
              width: 30px;
              font-size: 12px;
              background-color: #f6f7f9;
              ::v-deep .ant-input-number-input {
                padding: 0;
                padding-right: 5px;
                text-align: right;
              }
            }
            span {
              font-size: 12px;
              color: #000000;
            }
            .borderNumSpan {
              width: 30px;
              display: inline-block;
              text-align: right;
              padding-right: 5px;
              border: 1px solid #f6f7f9;
            }
            ::v-deep .ant-input-number-handler-wrap {
              display: none;
            }
          }
        }
      }
      .title-section {
        .flex-between {
          display: flex;
          justify-content: space-between;
          .reset {
            font-size: 12px;
            color: #9e9e9e;
            cursor: pointer;
          }
        }
        .control-content {
          display: flex;
          align-items: center;
          .title-name-input {
            width: 196px;
            height: 40px;
            border-radius: 4px;
            input {
              height: 100%;
              background-color: #f6f7f9;
              border: 0 none;
            }
          }
          .hidden-icon {
            width: 24px;
            height: 24px;
            background: #f6f7f9;
            border-radius: 4px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 16px;
            margin-left: 8px;
            cursor: pointer;
          }
        }
      }
      .link-box {
        margin-top: 24px;
      }
    }
  }
}
</style>
